package com.example.demo.common.vo;

import com.example.demo.common.exception.CommomMessage;

/**
 * @Name ExceptionResult
 * @Description API全局返回结果
 * @Author wen
 * @Date 2019-03-30
 */
public class ApiResult implements CommomMessage{

    private int code;

    private String msg;

    private long timestamp;

    private ApiResult(CommomMessage commomMessage){
        this.code = commomMessage.getCode();
        this.msg = commomMessage.getMsg();
        this.timestamp = System.currentTimeMillis();
    }

    public static ApiResult build(CommomMessage commomMessage){
        return new ApiResult(commomMessage);
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getMsg() {
        return this.msg;
    }

    public long getTimestamp() {
        return timestamp;
    }
}
